#ifndef PROTOCOLHANDLER_H
#define PROTOCOLHANDLER_H

#include <QtGlobal>
#include <QObject>
#include <QDebug>
#include <QRegExp>
#include <QMessageBox>
#include <QByteArray>
#include <QFile>
#include <QFileDialog>

//定义接收数据载入响应的解析报文结构体
struct PacketData {
    quint8 station;
    quint8 sid;
    quint32 startAddress;
    quint16 dataLength;
    quint16 crc;
    QByteArray rawData;
};


class ProtocolHandler : public QObject
{
    Q_OBJECT
public:
    explicit ProtocolHandler(QObject *parent = nullptr);
    //验证控制类命令输入的合法性
    bool validateMessageFormat(const QByteArray& data);
    //计算CRC
    unsigned short calculateCRC(const QByteArray &data);
    // CRC公有接口函数
    unsigned short publicCalculateCRC(const QByteArray& data);

    //......................................................................

    //分包函数
    QList<QByteArray> createPackets(quint8 station, quint8 sid, quint8 count, const QByteArray &data);
public slots:

signals:
};

#endif // PROTOCOLHANDLER_H
